//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<CCameraBase.cpp>
///	@path	~/src/scene/camera/
///	@date	2008/04/27
///	@desc	.

#include "config/config.h"

#include "graphics/common/CPerspectiveView.h"
#include "graphics/common/COrthoView.h"
#include "scene/camera/CCameraBase.h"

#include "mmsystem.h"

namespace xeres {

	IMPL_IOBJECT_CLASS( CCameraBase );

	// CCameraBase
	CCameraBase::CCameraBase( void )
	{
		// Creates a simple perspective view
		Ref<CPerspectiveView> pview = new CPerspectiveView();
		Ref<COrthoView> oview = new COrthoView();

		Vector<float> eye( 0.0f, 3.0f,-5.0f );
		Vector<float> dir( 0.0f, 0.0f, 0.0f );
		Vector<float> up( 0.0f, 1.0f, 0.0f );

		pview->LookAt( eye , dir , up );
		pview->SetProjection( D3DX_PI / 4 , 0.001f , 10000.f );

		m_view = pview;
	}
	// ~CCameraBase
	CCameraBase::~CCameraBase( void )
	{
	}
	// Construct
	void CCameraBase::Construct( ResourceLoader * loader , RefWeak<IData> res )
	{
		// Should not exec to here.
	}
	// AttachModel
	void CCameraBase::AttachModel( RefWeak<IModel> model )
	{
		// no model should be attached
	}
	// EnterScene
	void CCameraBase::EnterScene( RefWeak<IScene> scene )
	{

	}
	// LeaveScene
	void CCameraBase::LeaveScene( RefWeak<IScene> scene )
	{

	}
	// Tick
	void CCameraBase::Tick( const Frame & frame )
	{
// 		UINT  iTime  = timeGetTime() % 2000;
//  	FLOAT fAngle = iTime * (2.0f * D3DX_PI) / 2000.0f;
//  	D3DXMATRIXA16 matWorld;
//  	dx9::D3DXMatrixRotationY( &matWorld, fAngle );
//		rc.GetDX9()->SetTransform( D3DTS_WORLD, &matWorld );

// 		Matrix<float> view;
// 		dx9::D3DXMatrixMultiply( (D3DXMATRIX*)&view , &matView , &matWorld );
	}
	// Present
	void CCameraBase::Present( ScenePresentation& sp )
	{
	}
	// GetCameraView
	RefWeak<IView> CCameraBase::GetCameraView( void )
	{
		return m_view;
	}
	
} // namespace xeres
